package cn.icanci.learn.v1;

import cn.icanci.learn.v1.entity.UserInfo;
import cn.icanci.learn.v1.service.UserInfoService;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Tips: 第1课 使用ClassPathXmlApplicationContext的方式解析bean
 *
 * @author icanci
 * @date Created in 2021/06/08 00:49
 * @version 1.0
 */
public class Main {
	public static void main(String[] args) {
		// 方式1：加载配置文件的方式可以执行成功
		//        String xml = "//Users/icanci/ideaProjects/Source/spring-framework-5.2.0.RELEASE/icanci-new-learn/src/main/resources/spring-test.xml";
		//        ApplicationContext applicationContext = new FileSystemXmlApplicationContext(xml);

		// 方式2：也是加载配置文件的方式可以执行成功
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-test.xml");
		UserInfo user = (UserInfo) applicationContext.getBean("userInfo");
		System.out.println(user);
		UserInfoService userInfoService = (UserInfoService) applicationContext.getBean("userInfoService");
		UserInfo userInfoById = userInfoService.getUserInfoById();
		System.out.println(userInfoById);
	}
}
